package Chapter6.dao;

import org.hibernate.HibernateException;

import Chapter6.single_table.Book_Single_Table;
import Chapter6.single_table.Detail_Book_Simple_Table;

import learnning.dao.base.HibernateDao;

public class Book_Simple_TableDao extends HibernateDao {
	public void add(String name, String author, String nameAbstract) {
		try {
			begin();
			Detail_Book_Simple_Table book = new Detail_Book_Simple_Table(author);
			book.setName(name);
			Book_Single_Table bookTable = new Book_Single_Table();
			bookTable.setName(nameAbstract);
			getSession().save(bookTable);
			getSession().save(book);
			commit();
		} catch (HibernateException e) {
			rollback();
			e.printStackTrace();
		}
	}
}
